<?php
    require_once('../../code/global.php');
    require_once('/code/Category.php');
    require_once('/code/Product.php');
    require_once('/code/SiteInfo.php');
    $category=new Category();
    if(isset($_GET['cid'])) $cid=intval($_GET['cid']);
    else $cid=$category->getFirstCategoryId();
    if(isset($_GET['pid'])) $pid=intval($_GET['pid']);
    else {header('Location:/gallery/?cid='.$cid);exit;}
    $siteInfo=new SiteInfo();
    $s=$siteInfo->getSiteInfo();
    $product=new Product();
    $p=$product->getProductByID($pid);
    $p_g=$product->getProductGallery($pid);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="description" content="<?php echo $s['meta_keyword'] ?>" />  
        <meta name="keyword" content="<?php echo $s['meta_description'] ?>" />
        <title>Galleries | <?php echo $s['site_name'] ?></title>
        <link rel="shortcut icon" href="/styles/images/icon.ico" type="image/x-icon" />
        <link rel="stylesheet" href="/styles/styles.css" />
        <link rel="stylesheet" href="/styles/jquery.lightbox-0.5.css" />
        <link rel="stylesheet" href="/styles/jquery.thumbNav.css" />
        <script type="text/javascript" src="/script/jquery-1.6.1.min.js"></script>
        <script type="text/javascript" src="/script/jquery.lightbox-0.5.min.js"></script>
        <script type="text/javascript" src="/script/jquery.thumbNav.js"></script>
        <script type="text/javascript" src="/script/setLightbox.js"></script>
        <script type="text/javascript" src="/script/jquery.captionBox.js"></script>
        <script type="text/javascript">$(document).ready(function(){$('#thumbNav').thumbNav();});</script>
    </head>
    <body>
        <div id="container">
            <div id="stripe"></div>
            <a href="/" title="<?php echo $s['site_name'] ?>"><div id="header">
            </div></a>
            <div id="menu">
                <ul><li class="current"><a href="/gallery">Galleries</a></li><li class="seperator">|</li><li><a href="/news">News</a></li><li class="seperator">|</li><li><a href="/about">About us</a></li><li class="seperator">|</li><li><a href="/contact">Contact us</a></li></ul>
            </div>
            <div id="content">
                <div id="itemDisplay">
                    <h1><?php echo $p['subject'] ?></h1>
                    <div id="thumbNav"><div id="thumbNavWrapper">
                    <?php
                        foreach($p_g as $p_i){
                    ?>
                    <div class="galleryThumbDiv"><a href="<?php echo $p_i['img_url'] ?>" target="_blank" info="<?php echo $p_i['img_caption'] ?><br /><span class='title'><?php echo $p_i['img_descript'] ?></span>"><div class="imgWrapper" style="background:url('<?php echo $p_i['thumb_url'] ?>') no-repeat center"></div><div class="captionBox"><?php echo $p_i['img_caption'] ?></div></a></div>
                    <?php
                        }
                    ?>
                    </div></div>
                    <h3><span class="title">By <?php echo $p['name'] ?></span>,
                    <?php echo $p['date'] ?></h3>
                    <h3><?php echo $p['material'] ?></h3>
                    <h3><?php echo $p['size'] ?></h3>
                    <h3><?php echo $p['location'] ?></h3>
                    <h3>Code: <?php echo $p['code'] ?></h3>
                    <h3>Price: <?php echo $p['price'] ?></h3><br />
                    <h3>Introduction:</h3><?php echo $siteInfo->text2Html($p['intro'],1) ?>
                </div>
            </div>
            <div id="stripe"></div>
            <div id="footer">
                <?php $siteInfo->getFooterContent($s['site_name']); ?>
            </div>
        </div>
    </body>
</html>
